﻿using ConfExpert.Entities;
using ConfExpert.Forms.Base;
using DevTeam;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Araclar
{
    public partial class Screenshots : XForm
    {
        public Screenshots()
        {
            InitializeComponent();

            /*
            DataSet dsx = new DataSet();            
            DataTable dt = Session.DataManager.ExecuteDataTable("GetScreenshots");
            dsx.Tables.Add(dt);

            BindingSource bs = new BindingSource(dt.DataSet, dt.TableName);
            InitGridView(gridView1, bs);
            */

            gridView1.Init("GetScreenshots");
            gridView1.DoubleClick += new EventHandler(gridView1_DoubleClick);

            gridView1.OptionsBehavior.ReadOnly = true;
            gridView1.OptionsBehavior.Editable = false;
            gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
            //gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
            gridView1.FormatAsDateTime("Tarih");
            gridView1.AddSummary();

            gridView1.BestFitColumns();
        }

        void gridView1_DoubleClick(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                string ScreenshotId = gridView1.GetFocusedRowCellValue("ScreenshotId").ToString();
                using (ImageViewer v = new ImageViewer("select top 1 * from Screenshot where ScreenshotId = " + ScreenshotId))
                    v.ShowDialog();
            }
        }
    }
}